---
title: Morph Tools
---

## Code

```python cookbook/tools/morph_tools.py
from agno.agent import Agent
from agno.tools.models.morph import MorphTools

agent = Agent(
    instructions=[
        "You are a code editing assistant using Morph's advanced AI capabilities",
        "Help users modify, improve, and refactor their code intelligently",
        "Apply code changes efficiently while maintaining code quality",
    ],
    tools=[MorphTools()],
    markdown=True,
)

agent.print_response("Refactor this Python function to be more efficient and add type hints")
```

## Usage

<Steps>
  <Snippet file="create-venv-step.mdx" />

  <Step title="Set your API keys">
    ```bash
    export MORPH_API_KEY=your-morph-api-key
    export OPENAI_API_KEY=xxx
    ```
  </Step>

  <Step title="Install libraries">
    ```bash
    pip install -U openai agno
    ```
  </Step>

  <Step title="Run Agent">
    <CodeGroup>
    ```bash Mac
    python cookbook/tools/morph_tools.py
    ```

    ```bash Windows
    python cookbook/tools/morph_tools.py
    ```
    </CodeGroup>
  </Step>
</Steps>
